using Imaginarium.jobs.skills;
using System;
using System.Xml;
using Imaginarium.XML;
using Imaginarium.Factorys;
using Imaginarium.stats;
namespace Imaginarium.team {
    public class SkillDetail:ICloneable
    {

        public int skillLevel { get; set; }
        public Skill skill { get; set; }

        public SkillDetail()
        {

        }
        public SkillDetail(XmlElement element)
        {
            this.skillLevel = XmlHelper.getIntByTagname(element, XmlParameters.SKILL_LEVEL);
            this.skill = SkillFactory.getSkillById(XmlHelper.getIntByTagname(element,XmlParameters.SKILL_ID));
        }
        public SkillDetail(Skill skill, int skillLevel) {
            this.skillLevel = skillLevel;
            this.skill = skill;
        }

        public int calcMPCost() 
        {
            return (int)(skill.mpConsume * (1 + (skillLevel-1) / 3.0f ));
        }

        public BaseDamage calcBaseDamage()
        {
            BaseDamage calculatedBaseDamage = (BaseDamage)skill.baseDamage.Clone();
            calculatedBaseDamage.damage += skill.incrementalDamage.damage * (skillLevel - 1);

            return calculatedBaseDamage;
        }


        #region ICloneable Members

        public object Clone()
        {
            Type type = this.GetType();
            SkillDetail newSkillDetail = (SkillDetail)Activator.CreateInstance(type);
            newSkillDetail.skillLevel = this.skillLevel;
            newSkillDetail.skill = this.skill;
            return newSkillDetail;
        }

        #endregion
    }

}